/**
 * 2015年7月29日上午9:25:17
 * FuelConsumptionAlarmSched.javaFuelConsumptionAlarmSched
 */
package com.service.scheduler.sched;

import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.JobKey;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.Trigger;
import org.quartz.TriggerKey;

import com.service.cache.CacheManager;
import com.service.other.Logger;
import com.service.scheduler.job.FuelConsumptionAlarmJob;
import com.service.scheduler.server.SchedulerCreator;

/**
 * 2015年7月29日上午9:25:17
 *
 * 张
 */
public class FuelConsumptionAlarmSched {
	
	private Scheduler fuelConsumptionSched;
	
	public void init() {
		try {
			fuelConsumptionSched = SchedulerCreator.createScheduler(FuelConsumptionAlarmSched.class.getSimpleName(), 1, Trigger.DEFAULT_PRIORITY);
			initFuelConsumption();
			CacheManager.instance().schedMap.put(fuelConsumptionSched.getSchedulerName(),fuelConsumptionSched);
		} catch (SchedulerException e) {
			Logger.err(e);
		}
	}
	/*** 每天凌晨 00:00:00时执行该任务
	 * 
	 * @throws SchedulerException
	 */
	private void initFuelConsumption() throws SchedulerException {
		JobKey jobKey = SchedulerCreator.createJobKey("fuelConsumptionAlarm", "com.service.cache");
		TriggerKey triggerKey = SchedulerCreator.createTriggerKey("fuelConsumptionAlarm","com.service.cache");
		String cronExpr = "0 0 0 * * ?";
		JobDetail job = SchedulerCreator.createJob(jobKey, FuelConsumptionAlarmJob.class);
		CronTrigger cronTrigger = SchedulerCreator.createCronTrigger(triggerKey,cronExpr);
		fuelConsumptionSched.scheduleJob(job, cronTrigger);
	}
}
